package processingExample;
import processing.core.PApplet;
import processing.core.PFont;
//import processing.core.PImage;

import java.util.*;
import java.awt.event.*; //needed for MouseEvent

@SuppressWarnings("serial")
public class ProcessingExample4 extends PApplet
{
	//private PImage myPikachuPic = loadImage("pikachu.png");
	public static int x = 100;//keeps track of shape's x
	public static int y = 50;//keeps track of shape's y

	PFont myFont = loadFont("ArialNarrow-48.vlw"); //alternative... PFont myFont = createFont("Arial", 22);

	public void setup()
	{ 
		size(500, 500);
		background(255, 255, 70);
		frameRate(400);
		//line(x1, y1, x2, y2);
		//point(x, y);
		//quad(x1, y1, x2, y2, x3, y3, x4, y4);
		//rect(x, y, width, height);
		//triangle(x1, y1, x2, y2, x3, y3);
	}

	public void draw()
	{
		fill(0,0,0);
		textFont(myFont);
		text("My text goes here.", 100, 300, 500, 500);

		try
		{	
			int delay = 0; // delay for 0 sec
			int period = 2000; // repeat every 2 sec
			Timer timer = new Timer();

			timer.scheduleAtFixedRate(new TimerTask(){
				public void run()
				{
					stroke(190, 129, 247);
					fill(255, 0, 51);
					ellipse(x, y, 30, 70);
					x++;
				}
			}, delay, period);
		}
		catch(Exception e)
		{
		}
	}

	public void mousePressed(MouseEvent e)
	{
		System.out.println("position(x,y): " + e.getX() + "," + e.getY());
		stroke(0,0,0);
		fill(255,0,0);
		ellipse(e.getX(), e.getY(),25,25);
		//rect(e.getX(), e.getY(), 25, 25);
		//image(myPikachuPic, e.getX(), e.getY(), 140, 133);
	}
}
